import App from './App'
import store from './store'
import vuexStore from "@/store/$uv.mixin.js"
import plugin from './js_sdk/uni-admin/plugin'
import messages from './i18n/index.js'

if (process.env.NODE_ENV === 'development') {
	// import './mock/index.js' // 引入mock文件夹
}

const lang = uni.getLocale()

// #ifndef VUE3
import Vue from 'vue'
import VueI18n from 'vue-i18n'
import './uni.promisify.adaptor'
Vue.config.productionTip = false
Vue.use(VueI18n)
Vue.use(elementUI);
// 通过选项创建 VueI18n 实例
const i18n = new VueI18n({
	locale: lang, // 设置地区
	messages, // 设置地区信息
})
Vue.use(plugin)
App.mpType = 'app'
const app = new Vue({
	i18n,
	store,
	elementUI,
	...App,
	el: "#app",
})
app.$mount()
// #endif

// #ifdef VUE3
import {
	createSSRApp
} from 'vue'
import {
	createI18n
} from 'vue-i18n'

import ElementPlus from 'element-plus'
import 'element-plus/dist/index.css'

import * as ElementPlusIconsVue from '@element-plus/icons-vue'

export function createApp() {
	const app = createSSRApp(App)

	for (const [key, component] of Object.entries(ElementPlusIconsVue)) {
		app.component(key, component)
	}
	const i18n = createI18n({
		locale: lang,
		messages
	})
	app.use(i18n)
	app.use(plugin)
	app.use(store)
	app.mixin(vuexStore)
	app.use(ElementPlus);
	return {
		app
	}
}
// #endif